package com.bw.day_2.park

import androidx.lifecycle.MutableLiveData
import com.bw.base.entity.AddParkData
import com.bw.base.entity.AddParkEntity
import com.bw.base.entity.ParkEntity
import com.bw.base.entity.ParkEntityItem
import com.bw.base.mvvm.BaseViewModel
import com.bw.base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class ParkViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {
    val parkSuccess = MutableLiveData<ParkEntity>()

    fun park(id:Int){
        httpRequest({apiService.park(id)},{parkSuccess.value = it})
    }
    //跟据车位状态获取车位
    val parkStatusSuccess = MutableLiveData<ParkEntity>()
    fun parkStatus(id:String){
        httpRequest({apiService.parkStatus(id)},{parkStatusSuccess.value = it})
    }
    //添加车位
    val addParkSuccess = MutableLiveData<AddParkEntity>()
    fun addPark(addParkData: AddParkData){
        httpRequest({apiService.addPark(addParkData)},{addParkSuccess.value = it})
    }

}